package com.ruoyi.service.impl;

import com.ruoyi.domain.vo.ActivityListVo;
import com.ruoyi.domain.vo.ActivityPunchingVo;
import com.ruoyi.mapper.LowCarbonActivityMapper;
import com.ruoyi.service.ILowCarbonActivityService;
import com.ruoyi.system.domain.Activity;
import com.ruoyi.system.domain.ActivityApply;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LowCarbonActivityServiceImpl implements ILowCarbonActivityService {

    @Autowired
    private LowCarbonActivityMapper lowCarbonActivityMapper;

    @Override
    public List<Activity> getActivityListByOrganization(String organization, Long pageNum, Long pageSize) {
        Long offset = (pageNum - 1) * pageSize;
        return lowCarbonActivityMapper.getActivityListByOrganization(organization, offset, pageSize);
    }
//
//    @Override
//    public List<Activity> getActivityListLimit() {
//        return lowCarbonActivityMapper.getActivityListLimit();
//    }
//
//    @Override
//    public List<Activity> getActivityList() {
//        return lowCarbonActivityMapper.getActivityList();
//    }

//
//    @Override
//    public List<Activity> getActivityList(Activity activity, PageDTO pageDTO) {
////        Page<Activity>
//        return lowCarbonActivityMapper.getActivityList(activity, pageDTO);
//    }

    @Override
    public List<ActivityListVo> getActivityList(Long userId, Long pageNum, Long pageSize, String activityName){
        Long offset = (pageNum - 1) * pageSize;
        return lowCarbonActivityMapper.getActivityList(userId, offset, pageSize, activityName);
    }

    @Override
    public void organizeActivity(ActivityApply activityApply) {
        lowCarbonActivityMapper.organizeActivity(activityApply);
    }

    @Override
    public void ActivityPunching(ActivityPunchingVo activityPunchingVo){
        System.out.println(activityPunchingVo);
        lowCarbonActivityMapper.ActivityPunching(activityPunchingVo);
    }

    @Override
    public String agreeApply(Long activityApplyId){
        if (lowCarbonActivityMapper.getActivityApplyIsDel(activityApplyId) == 0){
            lowCarbonActivityMapper.agreeApply(activityApplyId);
            lowCarbonActivityMapper.delActivityApply(activityApplyId);
            return "已同意该活动申请";
        }
        else{
            return "该活动申请已被同意或已被删除";
        }
    }

    @Override
    public ActivityPunchingVo getActivityLogs(Long participateId){
        return lowCarbonActivityMapper.getActivityLogs(participateId);
    }
}
